From: Florian Müllner Date: Wed, 20 Mar 2019 15:19:47 +0000 (+0000) Subject: switchGestures: Do not hard-code allowed modes X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~861^2^2~23 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=b77e4975f0cfb2d3b3ab987b31db88179f4185bb;p=gnome-shell.git switchGestures: Do not hard-code allowed modes The touch/touchpad gestures to switch workspace currently hard-code the modes in which we want the gestures to work. While these modes are correct, the existing switch animation only works in NORMAL mode, not in the overview where the window group is hidden. The easiest way to address this is to handle both cases completely separately, namely use separate actions in- and outside the overview. Make the existing usable in that way by making the list of allowed modes a constructor parameter. https://gitlab.gnome.org/GNOME/gnome-shell/issues/516 --- diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js index 683a876f1..089035ba5 100644 --- a/js/ui/windowManager.js +++ b/js/ui/windowManager.js @@ -456,7 +456,8 @@ var TilePreview = class { }; var TouchpadWorkspaceSwitchAction = class { - constructor(actor) { + constructor(actor, allowedModes) { + this._allowedModes = allowedModes; this._dx = 0; this._dy = 0; this._enabled = true; @@ -496,15 +497,13 @@ var TouchpadWorkspaceSwitchAction = class { } _handleEvent(actor, event) { - let allowedModes = Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW; - if (event.type() != Clutter.EventType.TOUCHPAD_SWIPE) return Clutter.EVENT_PROPAGATE; if (event.get_touchpad_gesture_finger_count() != 4) return Clutter.EVENT_PROPAGATE; - if ((allowedModes & Main.actionMode) == 0) + if ((this._allowedModes & Main.actionMode) == 0) return Clutter.EVENT_PROPAGATE; if (!this._enabled) @@ -540,10 +539,11 @@ var WorkspaceSwitchAction = GObject.registerClass({ 'motion': { param_types: [GObject.TYPE_DOUBLE, GObject.TYPE_DOUBLE] }, 'cancel': { param_types: [] }}, }, class WorkspaceSwitchAction extends Clutter.SwipeAction { - _init() { + _init(allowedModes) { super._init(); this.set_n_touch_points(4); this._swept = false; + this._allowedModes = allowedModes; global.display.connect('grab-op-begin', () => { this.cancel(); @@ -551,14 +551,12 @@ var WorkspaceSwitchAction = GObject.registerClass({ } vfunc_gesture_prepare(actor) { - let allowedModes = Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW; - this._swept = false; if (!super.vfunc_gesture_prepare(actor)) return false; - return (allowedModes & Main.actionMode); + return (this._allowedModes & Main.actionMode); } vfunc_gesture_progress(actor) { @@ -1060,14 +1058,15 @@ var WindowManager = class { global.workspace_manager.override_workspace_layout(Meta.DisplayCorner.TOPLEFT, false, -1, 1); - let gesture = new WorkspaceSwitchAction(); + let allowedModes = Shell.ActionMode.NORMAL | Shell.ActionMode.OVERVIEW; + let gesture = new WorkspaceSwitchAction(allowedModes); gesture.connect('motion', this._switchWorkspaceMotion.bind(this)); gesture.connect('activated', this._actionSwitchWorkspace.bind(this)); gesture.connect('cancel', this._switchWorkspaceCancel.bind(this)); global.stage.add_action(gesture); // This is not a normal Clutter.GestureAction, doesn't need add_action() - gesture = new TouchpadWorkspaceSwitchAction(global.stage); + gesture = new TouchpadWorkspaceSwitchAction(global.stage, allowedModes); gesture.connect('motion', this._switchWorkspaceMotion.bind(this)); gesture.connect('activated', this._actionSwitchWorkspace.bind(this)); gesture.connect('cancel', this._switchWorkspaceCancel.bind(this));